/* $RCSFile: ADNDynInvoice.cs $
 * Apache license v2 2011 by Christian Surieux
 * $Source: ?/CRMWrapper3/DynEntities/ADNDynInvoice.cs $
 * $log$
 * Revision 6 2010/08/06 19:56:33  christian.surieux
 *   Added Log to All cs files
 */

using System;
using System.Diagnostics;
using System.Collections;
using System.ComponentModel;
using System.Collections.Generic;
using System.Text;
using CrmSdk;

namespace AddonNice.CRMWrapper
{
	public class ADNDynInvoice : ADNDynSalesBase
	{
        protected class Ftor: DFactor
        {
            public Ftor() : base(CrmStr.invoice)
            {}

            public override Type DynType
            { get { return typeof(ADNDynInvoice); } }

            public override string DynTypename
            {   get{ return CrmStr.invoice;}}

            public override DynEntity Build()
            {   return new ADNDynInvoice();}

            public override DynEntity Build(CRMWrapperBase w, InternalDynamicEntity dEntity, PropertyDescriptorCollection wproperties)
            {   return new ADNDynInvoice(w, dEntity, wproperties, null);}

            public override DynEntity Build(CRMWrapperBase w, string PrimaryFieldValue)
            {   return new ADNDynInvoice(w,PrimaryFieldValue);}

            public override DynEntity Build(CRMWrapperBase w,Guid PrimaryKeyValue)
            {   return new ADNDynInvoice(w,PrimaryKeyValue);}
        }

        static ADNDynInvoice(){new Ftor();} 

        /// <summary>
		/// Reserved for template methods: do not use directly
		/// </summary>
        public ADNDynInvoice(): base()
		{}

        public ADNDynInvoice(CRMWrapperBase w, string PrimaryFiedlValue)
			: base(w,CrmStr.invoice)
		{
			name = PrimaryFiedlValue;
		}

		public ADNDynInvoice(CRMWrapperBase w, Guid CrmId)
			: base(w,CrmStr.invoice, CrmId)
		{}

		public ADNDynInvoice(CRMWrapperBase w, InternalDynamicEntity e)

			: base(w,CrmStr.invoice,e,null,null)
		{}

		public ADNDynInvoice(CRMWrapperBase w, InternalDynamicEntity e,PropertyDescriptorCollection prop,InternalColumnSet s)

			: base(w,CrmStr.invoice,e,prop,s)
		{}

		/// <summary>
		/// Crm Key
		/// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public Guid invoiceid
		{
			get
			{
				return KeyPropertyValue(CrmStr.invoiceid);
			}
			set
			{
				AddKeyProperty(CrmStr.invoiceid, value);
			}
		}

        protected override void SetCrmIdProperty(Guid crmId)
        {
           if ( !dicProperty.ContainsKey(CrmStr.invoiceid) || KeyPropertyValue(CrmStr.invoiceid) != crmId )
                invoiceid   =   crmId;
        }

        public override Guid PrimaryKeyGuidValue
        {
           get
           {
                return invoiceid;
           }
           set
           {
               invoiceid    =   value;
           }
        }

         /// <summary>
        /// Gets or sets the priority of the invoice.
        /// High 2 Specifies high priority. 
        /// Low 0 Specifies low priority. 
        /// Medium 1 Specifies medium priority. 
        /// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public int prioritycode 
        {
            get
            {
                return PicklistPropertyIntValue(CrmStr.prioritycode);
            }
            set
            {
                AddPicklistProperty(CrmStr.prioritycode,value);
            }
        }

        /// <summary>
        /// Gets or sets the date by which the invoice has to be paid.
        /// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public string duedate
        {
            get
            {
                return DateTimePropertyValue(CrmStr.duedate);
            }
            set
            {
                AddDateTimeProperty(CrmStr.duedate,value);
            }
        }
 
        /// <summary>
        /// Gets or sets the date all products in the invoice were delivered.
        /// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public string datedelivered
        {
            get
            {
                return DateTimePropertyValue(CrmStr.datedelivered);
            }
            set
            {
                AddDateTimeProperty(CrmStr.datedelivered,value);
            }
        }

         
        /// <summary>
        /// Gets whether the order pricing is locked. 
        /// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public bool ispricelocked
        {
            get 
            {
                return BooleanPropertyValue(CrmStr.ispricelocked);
            }
            set
            {
            
                AddBooleanProperty(CrmStr.ispricelocked,value);
            }
        }

        /// <summary>
        /// Gets or sets the invoice number.  
        /// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public string invoicenumber
        {
            get
            {
                return StringPropertyValue(CrmStr.invoicenumber);
            }
            set
            {
                AddStringProperty(CrmStr.invoicenumber,value);
            }
        }
        
        /// <summary>
        /// virtual because on 'detail' records it is only a uniqueidentifier property
        /// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public Guid owningbusinessunit
        {
            get
            {
                return LookupPropertyValue(CrmStr.owningbusinessunit);
            }
            set
            {
                AddLookupProperty(CrmStr.owningbusinessunit,CrmStr.businessunit,value);
            }
        }
        
        /// <summary>
        /// Owner for this object
        /// </summary>
        [CrmDynAttribute(CrmStr.invoice)]
        public override Guid ownerid
        {
            get
            {
                if ( ContainsKey(CrmStr.ownerid) )
                    return OwnerPropertyValue(CrmStr.ownerid);
                return Guid.Empty;
            }
            set
            {
                AddOwnerProperty(CrmStr.ownerid,CrmStr.systemuser,value);
            }
        }
    }
}
